package sctu.edu.java.year2016.team01.chenhong.day20160522.chapter5_3;

/**
 * Created by Administrator on 2016/5/22.
 * 二维数组arr的所有元素和
 */
public class Sum {
    public static void main(String[] args) {

        int arr[][] = new int[][]{{1, 2, 3}, {9, 3, 7}, {9, 6, 5}};
        int sum = 0;
        System.out.println("二维数组arr为：");



        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr.length; j++) {
                System.out.print(arr[i][j] + "  ");
            }
            System.out.println();
        }



        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                sum += arr[i][j];
            }


        }


        System.out.println("二维数组arr的所有元素和为：" + sum);
    }
}
